<template>
  <div class="whole">
    <div class="top">
      <img :src="imgUrl+userInfo.avatar?imgUrl+userInfo.avatar:userImg" alt="" />
    </div>
    <div class="center">
      <div class="one">
        <span>{{ userInfo.userName }}</span>
      </div>
      <div class="two"></div>
      <div class="three">
        <span>北京第三医院</span>
        <span>骨科</span>
        <span>{{ userInfo.nickName }}</span>
      </div>
    </div>
    <div class="bottom">
      <a-form>
        <a-input
          class="centerInp"
          v-model="centerInp"
          placeholder="请输入患者姓名、患者ID"
        />
        <div class="centerBut" @click="onSearch(centerInp)"></div>
      </a-form>
    </div>
    <a-alert message="请输入患者姓名、患者ID" class="Aalert" v-if="aAlertShow" banner />
    <br />
  </div>
</template>

<script>
export default {
  data() {
    return {
      centerInp: "",
      userImg: require("../../../images/home/doctor.png"),
      imgUrl: "",
      userInfo: {},
      aAlertShow:false,
    };
  },
  mounted() {
    this.imgUrl = this.$config.imgUrl;
    this.getUserInfo();
  },
  methods: {
    getUserInfo() {
      let _this = this;
      // _this.userInfo = _this.$store.state.userInfo;
      _this.userInfo = JSON.parse(sessionStorage.getItem('userInfo'));
      console.log(_this.userInfo)
    },
    onSearch(value) {
      let _this = this;
      if(value == '') {
        _this.aAlertShow = true;
        setTimeout(() => {
          _this.aAlertShow = false;
        }, 1500);
      }else {
        let obj = {}
        obj.filter = value
        _this.aAlertShow = false;
        _this.$router.push({
          path: "/searchContent",
          query: obj,
        });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.whole {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  .top {
    width: 158px;
    height: 158px;
    border-radius: 50%;
    margin-left: -300px;
    img {
      width: 158px;
      height: 158px;
      border-radius: 50%;
    }
  }
  .center {
    margin: 31px 0 55px 0;
    margin-left: -300px;
    .one {
      width: 235px;
      font-size: 26px;
      font-weight: bold;
      color: #494949;
    }
    .two {
      width: 235px;
      height: 1px;
      background: #c1c1c1;
      margin: 10px 0 10px 0;
    }
    .three {
      width: 235px;
      font-size: 16px;
      color: #727272;
      display: flex;
      justify-content: space-around;
    }
  }
  .bottom {
    width: 540px;
    height: 36px;
    min-height: 36px;
    border-radius: 18px;
    border: solid 1px #9d9d9d;
    position: relative;
    margin-left: -300px;
    .centerInp {
      position: absolute;
      left: 0;
      width: 93%;
      border: none;
      border-style: none;
      background: none;
      box-shadow: none;
      border-radius: 18px;
      padding-left: 21px;
    }
    .centerBut {
      width: 18px;
      height: 18px;
      position: absolute;
      right: 19px;
      top: 8px;
      background-image: url(../../../images/home/icon-search.png);
      background-size: cover;
      background-size: 100% 100%;
    }
  }
  .Aalert {
    width: 300px;
    position: fixed;
    left: 50%;
    font-size: 16px;
  }
}
</style>